<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head>

</h:head>
<h:body>
	<h:form id="frmReq">
		<br />
		<h3 style="margin-top: 0">REQUISICAO</h3>
		<div align="left">
			<p:growl id="msgs" showDetail="true" />
			
			<p:messages id="messages" showDetail="true" autoUpdate="true"
				closable="true" />

			<p:commandButton value="Novo" actionListener="#{requisicaoBean.novo}"
				update="frmReq" disabled="#{requisicaoBean.btNovo}" />

			<p:commandButton value="Salvar"
				actionListener="#{requisicaoBean.salvar(1)}" update="frmReq"
				disabled="#{requisicaoBean.btSalvar}" />

			<p:commandButton value="Vincula usuário" type="button"
				onclick="PF('usuarios').show();"
				disabled="#{requisicaoBean.btVincUser}" />

			<p:commandButton value="Editar" disabled="#{requisicaoBean.btEdit}" 
				actionListener="#{requisicaoBean.editar(2)}"/>

			<p:commandButton value="Consulta" type="button"
				onclick="PF('requisicoes').show();" />

			<p:commandButton value="Excluir" update="frmReq"
				disabled="#{requisicaoBean.btExcluir}" actionListener="#{requisicaoBean.excluir}" />
			
			<p:commandButton value="Enviar Requisição" disabled="#{requisicaoBean.btEnviReq}"
				actionListener="#{requisicaoBean.enviarRequisicao}"/>

			<ui:include
				src="/privado/comercial/requisicao/requisicaoDadosGerais.xhtml" />

			<p:dialog id="dialogUsuario" header="Usuarios" widgetVar="usuarios"
				modal="true" height="350" width="600">

				<h:panelGrid columns="3">
				
				Nome:
				<p:inputText size="30" value="#{usuarioBean.nomeUsuario}" />

					<p:commandButton value="Pesquisar"
						actionListener="#{usuarioBean.listagem}" update="dataUsuario" />

				</h:panelGrid>

				<ui:include
					src="/privado/comercial/requisicao/tabelaPesquisaUsuario.xhtml" />

			</p:dialog>

			<p:dialog header="Consulta" widgetVar="requisicoes" modal="true"
				height="350" width="800">

				<h:panelGrid columns="7">
				
				Descrição:
				<p:inputText size="30" value="#{requisicaoBean.descReq}"/>
				 
				Data Inicial:
				<p:calendar value="#{requisicaoBean.dataIni}"/>
				
				Data Final:
				<p:calendar value="#{requisicaoBean.dataFim}"/>
				   
				<p:commandButton value="Pesquisar" actionListener="#{requisicaoBean.consultaRequisicao}"
					update="dataRequisicao"/>
								
				</h:panelGrid>
				
				<ui:include src="/privado/comercial/requisicao/tabelaPesquisaRequisicao.xhtml"/>	

			</p:dialog>
			
			<p:dialog header="Consulta" widgetVar="produtosCons" modal="true"
				height="350" width="800">
				
				<h:panelGrid columns="3">
				Descrição:
				<p:inputText value="#{requisicaoBean.descProduto}"/>
				
				<p:commandButton value="Pesquisar" actionListener="#{requisicaoBean.listaProdConsDesc}"
				 update="dataPesquisaProduto"/>
				
				</h:panelGrid>
				
				<ui:include src="/privado/comercial/requisicao/tabelaProdutosRequisicao.xhtml"/>
			
			</p:dialog>

			<p:fieldset legend="Produtos" toggleable="true" toggleSpeed="500">
				<p:ajax event="toggle" listener="#{fieldsetView.handleToggle}"
					update="msgs" />
				<h:panelGrid columns="2" cellpadding="5">
					<ui:include src="/privado/comercial/requisicao/tabelaProdutosInclusos.xhtml"/>
				</h:panelGrid>
			</p:fieldset>

		</div>
	</h:form>
</h:body>
</html>